package org.easyx.api.config;

import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.ComponentScan;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.servlet.config.annotation.EnableWebMvc;

import springfox.documentation.builders.ApiInfoBuilder;
import springfox.documentation.service.ApiInfo;
import springfox.documentation.service.Contact;
import springfox.documentation.spi.DocumentationType;
import springfox.documentation.spring.web.plugins.Docket;
import springfox.documentation.swagger2.annotations.EnableSwagger2;


/**
 *  <!-- swagger -->
	<dependency>
		<groupId>io.springfox</groupId>
		<artifactId>springfox-swagger2</artifactId>
		<version>${springfox.version}</version>
	</dependency>
	<dependency>
		<groupId>io.springfox</groupId>
		<artifactId>springfox-swagger-ui</artifactId>
		<version>${springfox.version}</version>
	</dependency>
 * 
 * 
 * 问题：
 * 	1、Swagger2 不显示api接口信息
 * 		解决方案：添加@ComponentScan注解
 * 
 */
@Configuration //注解让Spring来加载该类配置
@EnableWebMvc
@EnableSwagger2  //注解来启用Swagger2
@ComponentScan(basePackages = {"org.easyx"}) //必须存在 扫描的API Controller package name 也可以直接扫描class (basePackageClasses)
public class Swagger2Config{
	@Bean
	public Docket swaggerSpringMvcPlugin() {
		System.out.println("--------------SwaggerConfig---------------------");
		return new Docket(DocumentationType.SWAGGER_2)
				.apiInfo(apiInfo());
	}

	private ApiInfo apiInfo() {
		return new ApiInfoBuilder()
				.title("easyX提供的RESTful APIs")
//				.description("版权信息：©2017 Copyright. Powered By xiaojl.")
				.contact(new Contact("xiaojl", "", ""))
//				.license("Apache License Version 2.0")
//				.licenseUrl("https://github.com/springfox/springfox/blob/master/LICENSE")
				.version("1.0")
				.build();
	}
	
}